[
    async function( kuo,Context,context){
        Context.headers["content-type"] = 'application/json; charset=UTF-8';
        let LANG = this.LANG();
        let $DATA = Object.assign({},this.$DATA);
       
        let $Security = await Mem.Get("session/"+kuo.sessionid);
        if(! $Security ){
            $Security ={ adminid: 0};
        }
        if(typeof($Security['adminid']) == "undefined" ){
            $Security['adminid'] = 0;
        }
        if($Security['adminid'] < 1){
            $DATA.code = 99;
            $DATA.msg = "Go Login";
            Context.body =JSON.stringify($DATA);
            return ;
        }
        let fan = await Mode("admin").Loginok(kuo,$Security);
        if(fan){
            $DATA.code = fan;
            $DATA.msg = "Error " + kuo.sessionid;
            if($Security['adminid'] > 0){
                let $hash = 'safetoken/'+$Security['adminid'];
                $DATA.token = Mode("Tools").Uuid();
                Mem.Set($hash,$DATA.token);
            }
            Context.body = JSON.stringify($DATA);
            return ;
        }

    
        kuo.adminid = $Security['adminid'];
        let $hash = 'safetoken/'+kuo.adminid;
        $DATA.token = Mode("Tools").Uuid();
        Mem.Set($hash,$DATA.token);
        let  $kongzhi = kuo.Path[1]?kuo.Path[1]:"get";
        let  $db = await db('host_shuju');
        let  $_GET = kuo.get;
        let  $_POST = kuo.post;
        let  $chushi = true; 
        let  $features = await Kuoplus(kuo.class);
        let BENDIP =   $features['configure'] && $features['configure']['用户ip'] && $features['configure']['用户ip']['0'] !="" ?$features['configure']['用户ip']['0'] :"127.0.0.1";
        if($kongzhi == 'get'){

            let $page = Mode("Tools").Int($_GET['page']?$_GET['page']:1);
            let $limitx  =  Mode("Tools").Int($_GET['limit']?$_GET['limit']:10);
            if($limitx < 10 ){
                $limitx = 10;
            }else if($limitx > 100 ){
                $limitx = 100;
            }
            let $where ={};

            if(isset($_GET['name']) && $_GET['name'] !=""){
                $where['name LIKE']= '%'+$_GET['name']+'%';
            }

           
            let $data  = await $db.Where($where).Limit($limitx,$page).Order("id desc").Select();
            let $total = await $db.Where($where).Total();
            if(!$data){
                $data= [];
            }
            $DATA.code = 0;
            $DATA.count = $total;
            if($page == 1 && $chushi){
              
            }
    
            $DATA.data = $data;
    
    
    
        }else if($kongzhi == 'put'){
            let $id = Mode("Tools").Int($_POST['id']?$_POST['id']:0);
            let $data = await $db.Where({id: $id}).Find();
            if(!$data){
                $DATA.code = -1;
                $DATA.msg = LANG.admin_id_no;
                Context.body = JSON.stringify($DATA);
                return ;
            }
            $_POST['name'] = $data['name'];
            $_POST['atime']=  Mode("Tools").Time();
            $_POST['zhanghao'] =  $_POST['name'];
            let $fan = await $db.Where({id: $id}).Update($_POST);
            
            if($fan){

                await Kuolog('adminlog',kuo.adminid,3,{'yuan':$data,'data':$_POST},kuo.func_,kuo.class,kuo.ip);

                
                $DATA.code =1;
                $DATA.msg = LANG.put_ok;
                if($data['pass'] != $_POST['pass']){
                    await  $db.Qurey("alter user ?@? identified with mysql_native_password by ? ;flush privileges;",[$_POST['name'],BENDIP,$_POST['pass']]);
                }
              
                await this.SQldaoRu($id,$_POST);
                $_POST['zhixing'] = "";
                $_POST['daoru'] = "";
                $DATA.data = $_POST;
                
            }else{
                $DATA.code =-1;
                $DATA.msg = LANG.put_no;
            }
    
            
        }else if($kongzhi == 'add'){

            if($_POST['name'].indexOf("root")>-1){
                $_POST['name'] = "jinyong";
            }
            $_POST['name'] = $_POST['name'].toLowerCase();
            $_POST['atime'] =  Mode("Tools").Time();
            $_POST['zhanghao'] =  $_POST['name'];
            let $fan = await $db.Insert($_POST);
            if($fan){
                $DATA.code = 1;
                $DATA.msg = LANG.add_ok;
                await Kuolog('adminlog',kuo.adminid,4, $_POST ,kuo.func_,kuo.class,kuo.ip);
                let fanx = await  $db.Qurey("CREATE DATABASE ?? ",$_POST['name']);
                if(fanx){
                    await  $db.Qurey("alter database ?? character set utf8mb4",$_POST['name']);
                }
                fanx = await  $db.Qurey("CREATE USER  ?@? IDENTIFIED BY ? ;flush privileges;",[$_POST['name'],BENDIP,$_POST['pass']]);
                fanx =await  $db.Qurey("grant all privileges on ??.* to  ?@? ;flush privileges;",[$_POST['name'],$_POST['name'],BENDIP]);
                fanx = await  $db.Qurey("alter user ?@? identified with mysql_native_password by ? ;flush privileges;",[$_POST['name'],BENDIP,$_POST['pass']]);
                await this.SQldaoRu($fan,$_POST);

            }else{
                $DATA.code = -1;
                $DATA.msg = LANG.add_no;
            }

        }else if($kongzhi == 'del'){
    
            let $id = Mode("Tools").Int($_POST['id']?$_POST['id']:0);
            let $data = await $db.Where({id: $id}).Find();
            if(!$data){
                $DATA.code = -1;
                $DATA.msg = LANG.admin_id_no;
                Context.body = JSON.stringify($DATA);
                return ;
            }
            let sqlfile_ = '/attachment/backsql/'+$data.name+'/'+Mode("Tools").Uuid()+'.sql';
            let sqlfile = DIR +'www'+sqlfile_;
            MkDirs(DIR +'www/attachment/backsql/'+$data.name+'/');
            $db.Where({id: $id}).Update({ daochu:sqlfile_});
            var exec = require('child_process').exec;
            let zhixing = "mysqldump -u"+$data.zhanghao+" -p"+$data.pass+" -h"+MYSQLconfig.host+" -P"+MYSQLconfig.port+"  "+$data.name+" > "+sqlfile;
            exec(zhixing);
            $DATA.data = {daochu:sqlfile_};
            $DATA.code = 1;
        }
        Context.body = json_encode($DATA);
    }
]